pp108 : onbeforeapplicationclose Event

onbeforeapplicationclose Event


Fires before an application is closed.

Syntax

Inline HTML <HTML onbeforeapplicationclose="handler()"...>
Event property application.onbeforeapplicationclose = handler


Event Information

To invoke


  • Close an application by calling the close method of the application.container object.
  • Use the mouse to click the cross mark (error) on the top of a tab page.
  • Close an application by selecting the menu item "Close" from the applications shortcut menu on the taskbar.
Default Action Closes an application and initiates any action associated with this event.


Event Object Properties


Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query an event object for data.

Property Description
notCancellable Read-only. Boolean that defines whether the event can be cancelled. This value is true indicating that the event cannot be cancelled.
returnValue Boolean that defines one of the following values.
true Default. Application will be closed.
false Application will not be closed.


Remarks


The onbeforeapplicationclose event is similar to the window.document.body's onbeforeunload event. However, this event can be cancelled through script without prompting the input from the user whereas the body's event can be cancelled only by showing a message box for confirmation.

Also, the onbeforeapplicationclose event can be cancelled only when the application is closed using application.container.close() .

Example


The following example demonstrates the use of theonbeforeapplicationcloseevent.

<!-- HTML definition in the application running -->
<HTML onbeforeapplicationclose="checkForClosing()">
//Script for function handler onbeforeapplicationclose
function checkForClosing()
{
    //Ask the user for closing. If yes, then close
    if (prompt("Are you sure you want to close the application ?") == true)
        event.returnValue = true;
    else
        event.returnValue = false;
}

See Also


application